/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.yxw.live_vod_boot.service.impl;


import com.yxw.live_vod_boot.entity.YxSysUserEntity;
import com.yxw.live_vod_boot.enums.MqttTopicEnum;
import com.yxw.live_vod_boot.mapper.LiveCommentMapper;
import com.yxw.live_vod_boot.mapper.UserMapper;
import com.yxw.live_vod_boot.mqtt.MqttGateway;
import com.yxw.live_vod_boot.service.LiveGeneraUserProcessService;
import com.yxw.live_vod_boot.utils.AssertUtil;
import com.yxw.live_vod_boot.utils.JsonUtils;
import com.yxw.live_vod_boot.utils.UserUtil;
import com.yxw.live_vod_boot.vo.MqttLiveCommentVo;
import com.yxw.live_vod_facade.constant.LiveShopConstant;
import com.yxw.yxnet_cd_center.common.dto.BaseUserDTO;
import com.yxw.yxnet_cd_center.common.enums.ErrorCodeEnum;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
//import com.yxw.live_vod_boot.entity.YxSysUserEntity;
import javax.servlet.http.HttpServletRequest;
import com.yxw.live_vod_boot.utils.RedisManager;
//import com.yxw.live_vod_boot.mapper.UserMapper;
import com.yxw.live_vod_boot.vo.UserTokenVo;
import com.yxw.live_vod_boot.vo.LiveHomeUserCacheVO;
import com.yxw.yxnet_cd_center.common.constant.RedisIdConstant;
import javax.annotation.Resource;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yxw.live_vod_boot.dto.YxLiveWatchLogAddDTO;
import com.yxw.live_vod_boot.mapper.YxLiveWatchLogMapper;
import com.yxw.live_vod_boot.entity.YxLiveWatchLogEntity;
import com.yxw.live_vod_boot.entity.YxLiveUserWatchDurationEntity;
import com.yxw.live_vod_facade.vo.LivePushStreamRedisCacheVO;
import com.yxw.live_vod_boot.vo.LiveOnlineInRedisCacheVO;
import org.springframework.integration.redis.util.RedisLockRegistry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.redisson.api.RedissonClient;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import com.yxw.live_vod_boot.cache.QueueCache;
import com.yxw.live_vod_boot.entity.YxLiveShopUserEntity;
import com.yxw.live_vod_boot.mapper.YxLiveShopUserMapper;
import com.yxw.live_vod_boot.mapper.YxLiveUserWatchDurationMapper;
import com.yxw.yxnet_cd_center.common.exception.BaseException;

import java.util.Date;
import java.util.UUID;
import java.util.List;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.SerializationException;
import org.springframework.transaction.annotation.Transactional;
import com.yxw.live_vod_boot.vo.UserGotoLiveHomeVO;
/**
 * 普通用户直播处理逻辑
 * @author hjx
 * @date 2023-12-19
 */
@Slf4j
@Service
public class LiveGeneraUserProcessServiceImpl implements LiveGeneraUserProcessService{

    @Autowired
    private YxLiveWatchLogMapper oYxLiveWatchLogMapper;
    @Resource
    private RedissonClient oRedissonClient;
    
    @Resource
    private RedisLockRegistry redisLockRegistry;
    
    @Resource
    private RedisManager oRedisManager;
    
    @Resource
    private RedisTemplate redisTemplate;
    
    @Resource
    private QueueCache oQueueCache;

    @Autowired
    private YxLiveUserWatchDurationMapper oYxLiveUserWatchDurationMapper;

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private MqttGateway mqttGateway;
    @Autowired
    private LiveCommentMapper liveCommentMapper;
    
    @Autowired
    private YxLiveShopUserMapper oYxLiveShopUserMapper;    
    /**
     * 用户进入直播间
     * @param  liveId
     * @return BaseResult
     */
    @Override
    public BaseResult userGoIntoLiveHome(HttpServletRequest httpRequest,String liveId)
    {
        BaseUserDTO oBaseUserDTO = LiveProcessServiceImpl.getBaseUserInfo(httpRequest);
        if(null == oBaseUserDTO)
        {
            return BaseResult.failed("请先登录");
        }
        //LivePushStreamRedisCacheVO oLiveRedisCacheVO = (LivePushStreamRedisCacheVO)oRedisManager.get(LiveShopConstant.LIVE_PUSH_STREAM_CACHE_REDISKEY_PREFIX.concat(liveId));
        
        String mapKey = oBaseUserDTO.getUserId();
        //UserTokenVo tokenVo = (UserTokenVo) oRedisManager.get(RedisIdConstant.LOGIN_TOKEN + oBaseUserDTO.getUserId());
        if(oRedisManager.exsistInHash(LiveShopConstant.LIVE_SHOP_ONLINELIVE_HASH_REDISKEY, liveId))// && BeanUtil.isNotEmpty(tokenVo)
        {
            LiveHomeUserCacheVO oLiveHomeUserCacheVO = new LiveHomeUserCacheVO();
            oLiveHomeUserCacheVO.setComeInTime(System.currentTimeMillis());
            oLiveHomeUserCacheVO.setUserId(Long.valueOf(oBaseUserDTO.getUserId()));
            oLiveHomeUserCacheVO.setLiveId(liveId);
            //Lock oLock = redisLockRegistry.obtain(LiveShopConstant.LiveShopVisitUserCountRedisKeyPrefix.concat(liveId));
            //if(oLock.tryLock())
            //RLock oRLock = oRedissonClient.getLock(LiveShopConstant.LiveShopVisitUserCountRedisKeyPrefix.concat(liveId));
            //if(oRLock.tryLock())
            //{
            // 校验当前用户是不是已经被拉黑了
            Boolean isLimit = liveCommentMapper.checkLiveUserIsBanned(liveId, oBaseUserDTO.getUserId());
            AssertUtil.isFalse(isLimit, ErrorCodeEnum.USER_LIVE_USER_IS_BANNED);
                redisTemplate.executePipelined((RedisCallback<Object>) connection ->
                {
                    connection.openPipeline();
                    try
                    {
                        //在线的观众
                        String redisKey = LiveShopConstant.LIVE_SHOP_ONLINE_USER_COUNT_REDISKEY_PREFIX.concat(liveId);
                        connection.incrBy(redisTemplate.getKeySerializer().serialize(redisKey),1);
                        //观看过直播的观众
                        redisKey = LiveShopConstant.LIVE_SHOP_VISIT_TOTAL_USER_COUNT_REDISKEY_PREFIX.concat(liveId);
                        connection.incrBy(redisTemplate.getKeySerializer().serialize(redisKey),1);
                        //在线的观众Map
                        redisKey = LiveShopConstant.LIVE_SHOP_ONLINE_USERMAP_REDISKEY_PREFIX.concat(liveId);
                        connection.hSet(redisTemplate.getKeySerializer().serialize(redisKey), redisTemplate.getHashKeySerializer().serialize(mapKey), redisTemplate.getHashValueSerializer().serialize(oLiveHomeUserCacheVO));
                        //观看过直播的观众Map
                        redisKey = LiveShopConstant.LIVE_SHOP_VISIT_TOTAL_USERMAP_REDISKEY_PREFIX.concat(liveId);
                        connection.hSet(redisTemplate.getKeySerializer().serialize(redisKey), redisTemplate.getHashKeySerializer().serialize(mapKey), redisTemplate.getHashValueSerializer().serialize(oLiveHomeUserCacheVO));
                    }
                    catch(SerializationException e)
                    {
                        log.error("clientSendStartPushApply  redisTemplate.executePipelined命令异常:====================================>{}", e);
                        throw new BaseException("clientSendStartPushApply redisTemplate.executePipelined命令异常:"+e.getMessage());
                    }
                    finally
                    {
                        connection.close();
                    }
                    return null;
                });            
                //oRedisManager.incrBy(LiveShopConstant.LIVE_SHOP_VISIT_USER_COUNT_REDISKEY_PREFIX.concat(liveId), 1L);
                //oRedisManager.incrBy(LiveShopConstant.LIVE_SHOP_VISIT_TOTAL_USER_COUNT_REDISKEY_PREFIX.concat(liveId), 1L);
                //oRLock.unlock();
                //oRedisManager.setMapValue(LiveShopConstant.LIVE_SHOP_VISIT_MAP_REDISKEY_PREFIX.concat(liveId), mapKey, tokenVo);
            //}
            String onlineUser = null;
            String maxOnlineUser = null;
            Long onlineUserNumber = 0L;
            Long maxOnlineUserNumber = 0L;
            List<String> redisKeys = new java.util.ArrayList(); 
            redisKeys.add(LiveShopConstant.LIVE_SHOP_ONLINE_USER_COUNT_REDISKEY_PREFIX.concat(liveId));
            redisKeys.add(LiveShopConstant.LIVE_SHOP_ONLINE_USER_MAX_COUNT_REDISKEY_PREFIX.concat(liveId));
            List<Object> oList = oRedisManager.multiGet(redisKeys);
            
            onlineUser = String.valueOf(oList.get(0));
            maxOnlineUser = String.valueOf(oList.get(1));
            onlineUserNumber = Long.valueOf(onlineUser);
            maxOnlineUserNumber = Long.valueOf(maxOnlineUser);
            if(onlineUserNumber > maxOnlineUserNumber)
            {
                oRedisManager.incrBy(LiveShopConstant.LIVE_SHOP_ONLINE_USER_MAX_COUNT_REDISKEY_PREFIX.concat(liveId), 1);
            }
            Object oObject = null;
            Long virtualUserCount = null;
            oObject = oRedisManager.getMapValue(LiveShopConstant.LIVE_SHOP_MANAGER_ADDVIRTUALVISITOR_HASHMAP_KEY.concat(liveId),liveId);
            if(null == oObject)
            {
                virtualUserCount = 0L;
            }
            else
            {
                virtualUserCount = Long.valueOf(oObject.toString());
            }
            onlineUserNumber = onlineUserNumber + virtualUserCount;            
            UserGotoLiveHomeVO oUserGotoLiveHomeVO = new UserGotoLiveHomeVO();
            oUserGotoLiveHomeVO.setTotallUsers(onlineUserNumber.toString());
            oUserGotoLiveHomeVO.setUserComeInfor(oBaseUserDTO.getNickName() + "来了");
            sendMqttForUserInLive(liveId, oUserGotoLiveHomeVO);            
        }
        else
        {
            return BaseResult.failed("直播已结束，不能进入");
        }
        return BaseResult.success();
    }

    private void sendMqttForUserInLive(String liveId, UserGotoLiveHomeVO oUserGotoLiveHomeVO) {
        // 发送进入直播间消息
        MqttLiveCommentVo mqttVo = new MqttLiveCommentVo();
        mqttVo.setType(2);
        // 接收人ID
        mqttVo.setReceiverId(liveId);
        mqttVo.setSysTime(new Date());
        mqttVo.setContent(oUserGotoLiveHomeVO);
        /*
        // 内容
        if (null != oBaseUserDTO.getNickName()){
            mqttVo.setContent(oBaseUserDTO.getNickName() + "来了");
        } else {
            YxSysUserEntity yxSysUserEntity = userMapper.selectById(oBaseUserDTO.getUserId());
            if (null != yxSysUserEntity && null != yxSysUserEntity.getNickName()){
                mqttVo.setContent(yxSysUserEntity.getNickName() + "来了");
            }
        }
        */
        log.info("推送直播ID=============================================>{}", liveId);
        log.info("推送内容=============================================>{}", mqttVo.getContent());
        mqttGateway.sendToMqtt(MqttTopicEnum.LIVE_COMMENT_TOPIC.getTopic() + liveId, JsonUtils.toJson(mqttVo));
    }

    /**
     * 用户退出直播间
     * @param  liveId
     * @return BaseResult
     */
    @Override
    public BaseResult userLeaveLiveHome(HttpServletRequest httpRequest,String liveId)
    {
        BaseUserDTO oBaseUserDTO = LiveProcessServiceImpl.getBaseUserInfo(httpRequest);
        if(null == oBaseUserDTO)
        {
            return BaseResult.failed("请先登录");
        }
        final LivePushStreamRedisCacheVO oLiveRedisCacheVO = (LivePushStreamRedisCacheVO)oRedisManager.get(LiveShopConstant.LIVE_PUSH_STREAM_CACHE_REDISKEY_PREFIX.concat(liveId));
        String mapKey = oBaseUserDTO.getUserId();
        //UserTokenVo tokenVo = (UserTokenVo) oRedisManager.get(RedisIdConstant.LOGIN_TOKEN + oBaseUserDTO.getUserId());
        Long currentTime = System.currentTimeMillis();
        String strRedisKey = LiveShopConstant.LIVE_SHOP_ONLINE_USERMAP_REDISKEY_PREFIX.concat(liveId);
        LiveHomeUserCacheVO oLiveHomeUserCacheVO = (LiveHomeUserCacheVO)oRedisManager.getMapValue(strRedisKey, mapKey);
        //if(BeanUtil.isNotEmpty(oLiveRedisCacheVO) && BeanUtil.isNotEmpty(oLiveHomeUserCacheVO))
        if(oRedisManager.exsistInHash(LiveShopConstant.LIVE_SHOP_ONLINELIVE_HASH_REDISKEY, liveId) && BeanUtil.isNotEmpty(oLiveHomeUserCacheVO))    
        {
            currentTime = currentTime - oLiveHomeUserCacheVO.getComeInTime();
            //用户直播观看时长超过20分钟的店铺
            if(currentTime>1200000)
            {
                LambdaQueryWrapper<YxLiveUserWatchDurationEntity> oUserWatchDurationQueryWrapper = new LambdaQueryWrapper();
                oUserWatchDurationQueryWrapper.eq(YxLiveUserWatchDurationEntity::getUserInnerId, Long.valueOf(oBaseUserDTO.getUserId()));
                oUserWatchDurationQueryWrapper.eq(YxLiveUserWatchDurationEntity::getLiveShopId, oLiveRedisCacheVO.getLiveId());
                List<YxLiveUserWatchDurationEntity> oWatchDurationList = oYxLiveUserWatchDurationMapper.selectList(oUserWatchDurationQueryWrapper);
                if(oWatchDurationList.isEmpty())
                {
                    YxLiveUserWatchDurationEntity oYxLiveUserWatchDurationEntity = new YxLiveUserWatchDurationEntity();
                    oYxLiveUserWatchDurationEntity.setCreateTime(System.currentTimeMillis());
                    oYxLiveUserWatchDurationEntity.setUpdateTime(oYxLiveUserWatchDurationEntity.getCreateTime());
                    oYxLiveUserWatchDurationEntity.setLiveId(liveId);
                    oYxLiveUserWatchDurationEntity.setLiveShopId(oLiveRedisCacheVO.getLiveShopId());
                    oYxLiveUserWatchDurationEntity.setMaxDuration(currentTime);
                    oYxLiveUserWatchDurationMapper.insert(oYxLiveUserWatchDurationEntity);
                }
                else
                {
                    YxLiveUserWatchDurationEntity oYxLiveUserWatchDurationEntity = oWatchDurationList.get(0);
                    if(currentTime > oYxLiveUserWatchDurationEntity.getMaxDuration())
                    {
                        oYxLiveUserWatchDurationEntity.setUpdateTime(System.currentTimeMillis());
                        oYxLiveUserWatchDurationEntity.setMaxDuration(currentTime);
                        oYxLiveUserWatchDurationMapper.updateById(oYxLiveUserWatchDurationEntity);
                    }
                }
                strRedisKey = LiveShopConstant.LIVE_SHOP_USER_WATCHDURATION_HASHMAP_PREFIX.concat(oBaseUserDTO.getUserId());
                oRedisManager.setMapValue(strRedisKey, oLiveRedisCacheVO.getLiveShopId().toString(), oLiveRedisCacheVO.getLiveShopId().toString());
            }
        }        
        if(BeanUtil.isNotEmpty(oLiveRedisCacheVO))
        {    

            //RLock oLock = oRedissonClient.getLock(LiveShopConstant.LiveShopVisitUserCountRedisKeyPrefix.concat(liveId));
            //if(oLock.tryLock())
            //Lock oLock = redisLockRegistry.obtain(LiveShopConstant.LiveShopVisitUserCountRedisKeyPrefix.concat(liveId));
            //if(oLock.tryLock())            
            //{
                //oRedisManager.decrBy(LiveShopConstant.LIVE_SHOP_VISIT_USER_COUNT_REDISKEY_PREFIX.concat(liveId), 1L);
            //    oLock.unlock();
                //oRedisManager.delMapValue(LiveShopConstant.LIVE_SHOP_VISIT_MAP_REDISKEY_PREFIX.concat(liveId), mapKey);
                redisTemplate.executePipelined((RedisCallback<Object>) connection ->
                {
                    connection.openPipeline();
                    try
                    {                         
                        String redisKey = LiveShopConstant.LIVE_SHOP_ONLINE_USER_COUNT_REDISKEY_PREFIX.concat(liveId);                       
                        connection.decrBy(redisTemplate.getKeySerializer().serialize(redisKey),1);
                        
                        redisKey = LiveShopConstant.LIVE_SHOP_ONLINE_USERMAP_REDISKEY_PREFIX.concat(liveId);
                        connection.hDel(redisTemplate.getKeySerializer().serialize(redisKey), redisTemplate.getHashKeySerializer().serialize(mapKey));
                    }
                    catch(SerializationException e)
                    {
                        log.error("clientSendStartPushApply  redisTemplate.executePipelined命令异常:====================================>{}", e);
                        throw new BaseException("clientSendStartPushApply redisTemplate.executePipelined命令异常:"+e.getMessage());
                    }
                    finally
                    {
                        connection.close();
                    }
                    return null;
                });                 
            //}
        }        
        return BaseResult.success();
    }
    /**
     * 查询直播间用户数量
     * @param  liveId
     * @return BaseResult
     */
    @Override
    public BaseResult getLiveHomeUserCount(String liveId)
    {
        Object oObject = oRedisManager.get(LiveShopConstant.LIVE_SHOP_ONLINE_USER_COUNT_REDISKEY_PREFIX.concat(liveId));
        Long userCount = null;
        if(null == oObject)
        {
            userCount = 0L;
        }
        else
        {
            userCount = Long.valueOf(oObject.toString());
        }
        Long virtualUserCount = null;
        oObject = oRedisManager.getMapValue(LiveShopConstant.LIVE_SHOP_MANAGER_ADDVIRTUALVISITOR_HASHMAP_KEY.concat(liveId),liveId);
        if(null == oObject)
        {
            virtualUserCount = 0L;
        }
        else
        {
            virtualUserCount = Long.valueOf(oObject.toString());
        }
        userCount = userCount + virtualUserCount;
        return BaseResult.success(userCount);
    }
    /*** 
    * 增加用户观看日志
    * @param oYxLiveWatchLogDTO
    * @return BaseResult
    **/
    @Override
    public BaseResult liveWatchLogAddToCache(YxLiveWatchLogAddDTO oYxLiveWatchLogAddDTO)
    {
        oYxLiveWatchLogAddDTO.setId(UUID.randomUUID().toString().replaceAll("-", ""));
        oYxLiveWatchLogAddDTO.setCreateTime(System.currentTimeMillis());
        oQueueCache.liveWatchLogQueueOffer(oYxLiveWatchLogAddDTO);
        //oRedisManager.incrBy(LiveShopConstant.LIVE_SHOP_LIVE_TOTAL_WATCH_DURATION_LENGHT_REDISKEY_PREFIX.concat(oYxLiveWatchLogAddDTO.getLiveId()), oYxLiveWatchLogAddDTO.getWatchDuration());
        //oRedisManager.incrBy(LiveShopConstant.LIVE_SHOP_LIVE_TOTAL_WATCH_STREAM_LENGHT_REDISKEY_PREFIX.concat(oYxLiveWatchLogAddDTO.getLiveId()), oYxLiveWatchLogAddDTO.getWatchLength());
        return BaseResult.success(oYxLiveWatchLogAddDTO);
    }
    /*** 
    * 增加用户观看日志
    * @param oYxLiveWatchLogDTO
    * @return BaseResult
    
    public BaseResult liveWatchLogAddToDb(YxLiveWatchLogAddDTO oYxLiveWatchLogAddDTO)
    {
        YxLiveWatchLogEntity oYxLiveWatchLogEntity = oYxLiveWatchLogAddDTO.ConverToEntity();
        oYxLiveWatchLogMapper.insert(oYxLiveWatchLogEntity);
        redisTemplate.executePipelined((RedisCallback<Object>) connection ->
        {
            connection.openPipeline();
            try
            {
                String redisKey = LiveShopConstant.LIVE_SHOP_LIVE_TOTAL_WATCH_DURATION_LENGHT_REDISKEY_PREFIX.concat(oYxLiveWatchLogAddDTO.getLiveId());
                connection.incrBy(redisTemplate.getKeySerializer().serialize(redisKey),oYxLiveWatchLogAddDTO.getWatchDuration());

                redisKey = LiveShopConstant.LIVE_SHOP_LIVE_TOTAL_WATCH_STREAM_LENGHT_REDISKEY_PREFIX.concat(oYxLiveWatchLogAddDTO.getLiveId());
                connection.incrBy(redisTemplate.getKeySerializer().serialize(redisKey), oYxLiveWatchLogAddDTO.getWatchLength());
            }
            catch(SerializationException e)
            {
                log.error("clientSendStartPushApply  redisTemplate.executePipelined命令异常:====================================>{}", e);
                throw new BaseException("clientSendStartPushApply redisTemplate.executePipelined命令异常:"+e.getMessage());
            }
            finally
            {
                connection.close();
            }
            return null;
        });         
        return BaseResult.success();
    }
    * **/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public BaseResult liveWatchLogAddToDb(List<YxLiveWatchLogEntity> watchLogList)
    {
        /*
        Long watchDuration = 0L;
        Long watchLength = 0L;
        for(YxLiveWatchLogEntity watchLog : watchLogList)
        {
            watchDuration = watchDuration + watchLog.getWatchDuration();
            watchLength = watchLength + watchLog.getWatchLength();
        }
        */
        oYxLiveWatchLogMapper.saveByBatch(watchLogList);
        
        redisTemplate.executePipelined((RedisCallback<Object>) connection ->
        {
            connection.openPipeline();
            try
            {
                for(YxLiveWatchLogEntity watchLog : watchLogList)
                {
                    String redisKey = LiveShopConstant.LIVE_SHOP_LIVE_TOTAL_WATCH_DURATION_LENGHT_REDISKEY_PREFIX.concat(watchLog.getLiveId());
                    connection.incrBy(redisTemplate.getKeySerializer().serialize(redisKey),watchLog.getWatchDuration());
                    redisKey = LiveShopConstant.LIVE_SHOP_LIVE_TOTAL_WATCH_STREAM_LENGHT_REDISKEY_PREFIX.concat(watchLog.getLiveId());
                    connection.incrBy(redisTemplate.getKeySerializer().serialize(redisKey), watchLog.getWatchLength());
                    redisKey = LiveShopConstant.LIVE_SHOP_USER_WATCHLOG_HASHMAP_PREFIX.concat(watchLog.getLiveId());
                    String hashKey = watchLog.getId();
                    connection.hDel(redisTemplate.getKeySerializer().serialize(redisKey), redisTemplate.getKeySerializer().serialize(hashKey));
                }
            }
            catch(SerializationException e)
            {
                log.error("clientSendStartPushApply  redisTemplate.executePipelined命令异常:====================================>{}", e);
                throw new BaseException("clientSendStartPushApply redisTemplate.executePipelined命令异常:"+e.getMessage());
            }
            finally
            {
                connection.close();
            }
            return null;
        });         
        return BaseResult.success();
    }
     /**
     * 查看店铺是否在开播
     * @param  liveShopId
     * @return BaseResult
     */
    @Override
    public BaseResult userCheckShopLiveStreamIsActive(Long liveShopId)
    {
        String redisKey = LiveShopConstant.LIVE_SHOP_ONLINELIVE_SHOPIDKEY_HASH_REDISKEY;
        LiveOnlineInRedisCacheVO oLiveOnlineInRedisCacheVO = (LiveOnlineInRedisCacheVO)oRedisManager.getMapValue(redisKey, liveShopId.toString());
        if(null != oLiveOnlineInRedisCacheVO)
        {
            return BaseResult.success(oLiveOnlineInRedisCacheVO);
        }
        else
        {
            return BaseResult.failed("200","该店铺没在直播");
        }
    }
    /*** 
    * 根据店铺Id查询店铺在线员工
    * @param liveShopId
    * @param userId
    * @return List<YxLiveShopUserEntity>
    **/
    @Override
    public BaseResult getShopUserInfor(Long liveShopId,Long userId)
    {
        QueryWrapper<YxLiveShopUserEntity> oYxLiveShopUserQueryWrapper = new QueryWrapper();
        oYxLiveShopUserQueryWrapper.eq("live_shop_id",liveShopId);
        oYxLiveShopUserQueryWrapper.eq("shop_user_id",userId.toString());
        return  BaseResult.success(oYxLiveShopUserMapper.selectOne(oYxLiveShopUserQueryWrapper)); 
    }
}